/*
 * Copyright 2011-2020 the original author or authors.
 *
 * Licensed under the Apache License, Version 2.0.
 * See `LICENSE` in the project root for license information.
 */

package me.ijleex.mgmt.system.user.mapper;

import java.util.List;

import org.apache.ibatis.annotations.Mapper;

import me.ijleex.mgmt.framework.mybatis.mapper.MyBatisMapper;
import me.ijleex.mgmt.system.user.entity.User;

/**
 * 用户 数据层
 *
 * @author liym
 * @since 2019-03-14 11:03:53 By 'codegen'
 */
@Mapper
public interface UserMapper extends MyBatisMapper<User> {

    /**
     * 查询用户信息
     *
     * @param user 用户条件信息
     * @return 用户信息
     * @since 2019-05-17 15:36
     */
    default User getUser(User user) {
        List<User> users = this.selectList(user);
        return users == null || users.isEmpty() ? null : users.get(0);
    }

    /**
     * 根据用户名查询用户
     *
     * @param username 用户名
     * @return 用户
     * @since 2020-08-09 10:00
     */
    User selectByUsername(String username);

    /**
     * 判断用户名是否存在
     *
     * @param username 用户名
     * @return true/false
     */
    Boolean isUsernameExists(String username);

}
